<html>
<head><meta charset="utf-8"><title>error: failed to get bitcode from object file for LTO (Bitc · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/error.3A.20failed.20to.20get.20bitcode.20from.20object.20file.20for.20LTO.20(Bitc.html">error: failed to get bitcode from object file for LTO (Bitc</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225147869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/error%3A%20failed%20to%20get%20bitcode%20from%20object%20file%20for%20LTO%20%28Bitc/near/225147869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Colin Finck <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/error.3A.20failed.20to.20get.20bitcode.20from.20object.20file.20for.20LTO.20(Bitc.html#225147869">(Feb 04 2021 at 11:35)</a>:</h4>
<p>I'm still trying to upgrade the Yocto meta-rust layer (<a href="https://github.com/meta-rust/meta-rust">https://github.com/meta-rust/meta-rust</a>) to Rust 1.49.0. Build is now progressing further after fixing the target JSON and adapting to the new x.py.<br>
However, the built compiler cannot compile my LTO-enabled applications. I'm now getting:</p>
<div class="codehilite"><pre><span></span><code>error: failed to get bitcode from object file for LTO (Bitcode section not found in object file)
</code></pre></div>
<p>How to debug that further?<br>
I see some <code>rustc</code> calls with <code>--emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto</code> and some with <code>--emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no</code>. The error message doesn't tell which particular object file is lacking bitcode information.</p>
<p>This still worked with Rust 1.46.0 from the meta-rust layer. Did anything related change during that time?</p>



<a name="225162754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/error%3A%20failed%20to%20get%20bitcode%20from%20object%20file%20for%20LTO%20%28Bitc/near/225162754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Colin Finck <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/error.3A.20failed.20to.20get.20bitcode.20from.20object.20file.20for.20LTO.20(Bitc.html#225162754">(Feb 04 2021 at 14:03)</a>:</h4>
<p>Got some more information now with <code>RUSTC_LOG=debug</code> enabled:</p>
<div class="codehilite"><pre><span></span><code>[1;32m INFO[0m [2mrustc_codegen_llvm::back::lto[0m adding bitcode from std.std.efvtyrxz-cgu.0.rcgu.o
error: failed to get bitcode from object file for LTO (Bitcode section not found in object file)
</code></pre></div>
<p>So for some reason, my <code>libstd</code> is built without a bitcode section. But why??</p>



<a name="225170904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/error%3A%20failed%20to%20get%20bitcode%20from%20object%20file%20for%20LTO%20%28Bitc/near/225170904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/error.3A.20failed.20to.20get.20bitcode.20from.20object.20file.20for.20LTO.20(Bitc.html#225170904">(Feb 04 2021 at 15:05)</a>:</h4>
<p>What build command are you running?</p>



<a name="225277436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/error%3A%20failed%20to%20get%20bitcode%20from%20object%20file%20for%20LTO%20%28Bitc/near/225277436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Colin Finck <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/error.3A.20failed.20to.20get.20bitcode.20from.20object.20file.20for.20LTO.20(Bitc.html#225277436">(Feb 05 2021 at 09:39)</a>:</h4>
<p>libstd is built just like any other Rust crate using cargo here: <a href="https://github.com/meta-rust/meta-rust/blob/master/recipes-devtools/rust/libstd-rs.inc">https://github.com/meta-rust/meta-rust/blob/master/recipes-devtools/rust/libstd-rs.inc</a><br>
But my LTO problem is fixed now: <a href="https://github.com/meta-rust/meta-rust/pull/295">https://github.com/meta-rust/meta-rust/pull/295</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>